<extend name="Public/base" />
<block name="body">
    <!-- 标题栏 -->
	<div class="main-title">
		<h2>APP管理</h2>
	</div>
	<div class="cf">
		<div class="fl">
	          <a class="btn" href="{:U('App/addApp')}">新 增</a>
	         <!--  <button class="btn ajax-post" url="{:U('changeStatus?method=resume')}" target-form="ids">启 用</button> -->
	          <button class="btn ajax-post" url="{:U('changeStatus?method=forbid')}" target-form="ids">禁 用</button>
	          <button class="btn ajax-post confirm" url="{:U('changeStatus?method=delete')}" target-form="ids">删 除</button>
        </div>
		
        <!-- 高级搜索 -->
		<div class="search-form fr cf">
			<div class="sleft">
				<input type="text" name="condition" class="search-input" value="{:I('condition')}" placeholder="请输入ID">
				<a class="sch-btn" href="javascript:;" id="search" url="{:U('App/appList')}"><i class="btn-search"></i></a>
			</div>
		</div>
    </div>
    
	<!-- 数据列表 -->
	<div class="data-table table-striped">
	<table class="">
    <thead>
        <tr>
		<th class="row-selected row-selected"><input class="check-all" type="checkbox"/></th>
		<th class="">ID</th>
		<th class="">APP名称</th>
		<th class="">APP版本</th>
		<th class="">API版本</th>
		<th class="">APP平台</th>
		<th class="">更新类型</th>
		<th class="">更新意见</th>
		<th class="">创建时间</th>
		<th class="">更新时间</th>
		<th class="">状态</th>
		<th class="">操作</th>
		</tr>
    </thead>
    <tbody>
		<notempty name="_list">
		<volist name="_list" id="vo">
		<tr>
			<td><input class="ids" type="checkbox" name="id[]" value="{$vo.id}" /></td>
			<td>{$vo.id}</td>
			<td>{$vo.app_name}</td>
			<td>{$vo.app_version}</td>
			<td>{$vo.api_version}</td>
			<td>{$vo.platform_text}</td>
			<td>{$vo.update_type_text}</td>
			<td>{$vo.update_status_text}</td>
			<td>{:date('Y-m-d H:i:s', $vo['create_time'])}</td>
			<td>{:date('Y-m-d H:i:s', $vo['update_time'])}</td>
			<td>{$vo.status_text}</td>
			<td>
				<a href="{:U('App/editApp', array('id' => $vo['id']))}">编辑</a>
				<a href="{:U('App/appDetail', array('id' => $vo['id']))}">详情</a>
				<if condition="$vo['status'] eq 0">
					<a href="{:U('App/enableApp', array('id' => $vo['id'], 'platform' => $vo['platform']))}">启用</a>
				<elseif condition="$vo['status'] eq 1" />
					<span style="color:red;">已启用</span>
				</if>
			</td>
		</tr>
		</volist>
		<else/>
		<td colspan="6" class="text-center"> aOh! 暂时还没有内容! </td>
		</notempty>
	</tbody>
    </table>

	</div>
    <div class="page">
        {$_page}
    </div>
</block>

<block name="script">
<script type="text/javascript" charset="utf-8">
	//搜索功能
	$("#search").click(function(){
		var url = $(this).attr('url');
	    var query  = $('.search-form').find('input').serialize();
	    query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g,'');
	    query = query.replace(/^&/g,'');
	    if( url.indexOf('?')>0 ){
	        url += '&' + query;
	    }else{
	        url += '?' + query;
	    }
		window.location.href = url;
	});
	//回车搜索
	$(".search-input").keyup(function(e){
		if(e.keyCode === 13){
			$("#search").click();
			return false;
		}
	});
	
	//更新缓存功能
	$("#update_cache").click(function(){
		$(this).prop('disabled',true);
		ajaxRequest("{:U('Api/cacheApi')}", {}, {"func":function(data){
			if(data != null && data != undefined && data.error ==0) {
				updateAlert('更新成功', 'alert-success');
			} else {
				updateAlert('更新失败', 'alert-error');
			}
			
			//定时关闭弹出框
			setTimeout(function(){
				$('.close').click();
				window.location.href = '__SELF__';
            },1500);
		}});
	});
	
    //导航高亮
    <if condition="I('status') eq -1">
    	highlight_subnav('{:U('Api/deleteList?status=-1')}');
    <else />
    	highlight_subnav('{:U('Api/apiList')}');
    </if>
    
</script>
</block>